require(['./config'], () => {
    require(['template', 'request', 'swiper', 'header', 'footer', 'toTop'], (template, request, Swiper, header) => {
        class Index {
            constructor() {
                this.getCategory()
                this.Swiper()
                this.toTop()
                header.fideIn()
            }
            getCategory() {
                // 颗粒度
                $.get('libs/json/data.json', resp => {
                    this.renderCategory(resp)

                })
                $.get('libs/json/lunbo.json', resp => {
                    this.rCategory(resp)
                })
                $.get('libs/json/glist.json', resp => {
                    this.goodsCategory(resp)
                })
            }
            renderCategory(list) {
                // console.log(list)
                $('#blk_index_fix').html(template('tmpl_index_fix', { 'list': list }))
            }
            rCategory(cd) {
                // console.log(cd)
                $('#blk_index_focus').html(template('tmpl_index_focus', { 'list': cd }))
            }
            goodsCategory(glist) {
                $('#goods-list').html(template('tmplate-list', { 'list': glist }))
            }

            Swiper() {
                var mySwiper = new Swiper('.swiper-container', {
                    autoplay: true,
                    loop: true
                })

                //如果你初始化时没有定义Swiper实例，后面也可以通过Swiper的HTML元素来获取该实例
                new Swiper('.swiper-container')
                var mySwiper = document.querySelector('.swiper-container').swiper
                mySwiper.slideNext();
            }
            toTop() {
                $('.totop').toTop();
            }

        }
        new Index()
    })
})